"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _useRealtimeRef = _interopRequireDefault(require("../useRealtimeRef"));
/**
 * 组件卸载时执行 fn
 * @param fn
 */
var useUnmount = function useUnmount(fn) {
  var fnRef = (0, _useRealtimeRef.default)(fn);
  (0, _react.useEffect)(function () {
    return function () {
      var _fnRef$current;
      return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call(fnRef);
    };
  }, []);
};
var _default = useUnmount;
exports.default = _default;